package day1;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

public class SocketClient {
    public static void main(String[] args) throws IOException, InterruptedException {
        SocketChannel sc = SocketChannel.open();
        //连接服务端
        sc.connect(new InetSocketAddress("127.0.0.1",6666));
//        String str = "哈哈哈哈";
//        for (int i = 0; i < 100; i++) {
//            sc.write(ByteBuffer.wrap(str.getBytes(StandardCharsets.UTF_8)));
//            Thread.sleep(100);
//        }
//        Thread.sleep(100000);
        String str = "hello world hello world11111\n";
        sc.write(Charset.defaultCharset().encode(str));
        System.in.read();
//        sc.close();
    }
}
